﻿//-----------------------------------------------------------------------
// <copyright file="IComponentProvider.cs" company="Nathan Miller">
// Copyright (c) Nathan Miller.
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
// 
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
// 
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// </copyright>
//-----------------------------------------------------------------------
namespace TileTool.Component
{
    using System;
    using System.Collections.Generic;
    using TileTool.Threading;
    using TileTool.Threading.Future;

    /// <summary>
    /// Interface for class which collects components and gives access
    /// to them.
    /// </summary>
    public interface IComponentProvider
    {
        /// <summary>
        /// Gets an enumeration of all components the provider knows about.
        /// </summary>
        IEnumerable<IComponent> AllComponents
        {
            get;
        }

        /// <summary>
        /// Called to tell the component provider to collect all components.
        /// </summary>
        /// <returns>Returns a future object which tracks the state of the collection process.</returns>
        IFuture Collect();

        /// <summary>
        /// Get all components which are of the passed type.
        /// </summary>
        /// <typeparam name="T">Type of component to get.</typeparam>
        /// <returns>Returns an enumeration of all components of the provided type.</returns>
        IEnumerable<T> GetComponents<T>() where T : class, IComponent;

        /// <summary>
        /// Get a component by the passed name.
        /// </summary>
        /// <param name="name">Name of the component to locate.</param>
        /// <returns>Returns the component with the passed name or null if none was found.</returns>
        IComponent GetComponentByName(string name);

        /// <summary>
        /// Get a component by the passed name.
        /// </summary>
        /// <typeparam name="T">Type of component to get.</typeparam>
        /// <param name="name">Name of the component to locate.</param>
        /// <returns>Returns the component with the passed name or null if none was found.</returns>
        T GetComponentByName<T>(string name) where T : class, IComponent;
    }
}
